<template>
  <basic-container>
    <avue-crud :option="option"
               :data="data"
               ref="crud"
               v-model="form"
               :table-loading="loading"
               :permission="permissionList"
               :page="page"
               @search-change="searchChange"
               @search-reset="searchReset"
               @current-change="currentChange"
               @size-change="sizeChange"
               @on-load="onLoad">
    </avue-crud>
  </basic-container>
</template>

<script>
// import {
//   getList
// } from "@/api/base/member/userPredepositLog";
import { mapGetters } from "vuex";

export default {
  data () {
    return {
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      option: {
        refreshBtn: false,
        columnBtn: false,
        addBtn: false,
        searchBtn: false,
        menu: false,
        selection: false,
        size: 'mini',
        border: true,
        viewBtn: true,
        align: 'center',
        rowKey: 'id',
        height: 'auto',
        // calcHeight: 380,
        menuWidth: 300,
        column: [
          {
            label: "会员名称",
            prop: "userName",
            fixed: true,
            search: true,
            rules: [{
              required: true,
              message: "请输入用户id",
              trigger: "blur"
            }]
          },
          {
            label: "提交时间",
            prop: "addTime",
            fixed: true,
            rules: [{
              required: true,
              message: "请输入店铺提交时间",
              trigger: "blur"
            }]
          },
          {
            label: "金额",
            prop: "pdLogAmount",
            fixed: true,
            rules: [{
              required: true,
              message: "请输入金额",
              trigger: "blur"
            }]
          },
          {
            label: "预存款类型",
            prop: "pdType",
            fixed: true,
            rules: [{
              required: true,
              message: "请输入金额",
              trigger: "blur"
            }]
          },
          {
            label: "操作类型",
            prop: "pdOpType",
            fixed: true,
            rules: [{
              required: true,
              message: "请输入操作类型",
              trigger: "blur"
            }]
          },
          {
            label: "支付类型",
            prop: "payType",
            fixed: true,
            rules: [{
              required: true,
              message: "请输入账户类型",
              trigger: "blur"
            }]
          },
          {
            label: "支付状态",
            prop: "payStatus",
            fixed: true,
            rules: [{
              required: true,
              message: "请输入操作前金额",
              trigger: "blur"
            }]
          },
          {
            label: "描述",
            prop: "paLogInfo",
            fixed: true,
            rules: [{
              required: true,
              message: "请输入操作之后的金额",
              trigger: "blur"
            }]
          }
        ]
      },
      data: []
    };
  },
  computed: {
    ...mapGetters(["permission", 'userInfo']),
    permissionList () {
      return {
        addBtn: this.vaildData(this.permission["/mall-cloud-base/predepositLog/addItem"], false),
        viewBtn: this.vaildData(this.permission["/mall-cloud-base/predepositLog/detail"], false),
        delBtn: this.vaildData(this.permission["/mall-cloud-base/predepositLog/delete"], false),
        editBtn: this.vaildData(this.permission["/mall-cloud-base/predepositLog/editItem"], false)
      };
    },
  },
  methods: {
    searchReset () {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange (params,done) {
      this.query = params;
      this.onLoad(this.page, params,done);
    },
    currentChange (currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange (pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange () {
      this.onLoad(this.page);
    },
    onLoad (page, params = {},done) {
      this.loading = true;
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        if(done){
          done();
        }
        // this.loading = false;
        // const data = res.data;
        // this.page.total = data.count;
        // this.data = data.data;
        if(res.status == 200) {
          this.loading = false;
          this.data = res.data.data
          this.page.total = res.data.count;
        }
      });
    }
  }
};
</script>

<style>
.avue-crud__menu {
  min-height:0!important;
  margin-bottom:0px;
}
</style>
